package com.windbell.rest.controllers

import com.windbell.rest.RestRequestInfo
import com.windbell.rest.server.service.risk.RiskCategoryCriteriaMapper
import com.windbell.rest.server.service.risk.RiskCategoryMapper
import com.windbell.rest.services.CCRiskService
import com.windbell.rest.services.RestResult
import com.windbell.rest.shared.risk.UIRiskCategory
import com.windbell.rest.shared.risk.UIRiskCategoryCriteria
import com.windbell.rest.shared.risk.UIRiskCause
import com.windbell.rest.shared.risk.UIRiskCheck
import com.windbell.rest.shared.risk.UIRiskCheckItem
import com.windbell.rest.shared.risk.UIRiskCheckItemCriteria
import com.windbell.rest.shared.risk.UIRiskCommonIssue
import com.windbell.rest.shared.risk.UIRiskFixType
import com.windbell.rest.shared.risk.UIRiskLevel
import com.windbell.rest.shared.risk.UIRiskReport
import com.windbell.rest.shared.risk.UIRiskSubCategory
import com.windbell.rest.shared.risk.UIRiskType
import edu.fudan.langlab.xtendannotation.restservice.NgService
import java.util.Collection
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RestController

import static com.windbell.rest.services.RestUtil.*
import com.windbell.rest.shared.risk.UIRiskCheckCriteria
import com.windbell.rest.shared.risk.UIRiskCheckTarget
import com.windbell.rest.shared.risk.RestRiskCheckItemStatus
import com.windbell.rest.shared.risk.RestRiskCheckStatus

@RestController
@NgService
class CCRiskController {
	@Autowired CCRiskService riskService
	@Autowired
    private RiskCategoryCriteriaMapper riskCategoryCriteriaMapper
    @Autowired
    private RiskCategoryMapper riskCategoryMapper
    
	
//	// 获取隐患列表
//	@RequestMapping("/windbell/riskCategories")
//	def RestResult<Collection<UIRiskCategory>> getRiskCategoryList() {
//		callWithResult[
//			return riskService.riskCategoryList
//		]
//	}
//	// 获取特定隐患大类下隐患小类列表
//	@RequestMapping("/windbell/riskSubCategories")
//	def RestResult<Collection<UIRiskSubCategory>> getRiskSubCategoryList(Long riskCategoryId){
//		callWithResult[
//			return riskService.getRiskSubCategoryList(riskCategoryId)
//		]
//	}
//	// 获取特定隐患小类下隐患不合格项列表
//	@RequestMapping("/windbell/riskCommonIssues")
//	def RestResult<Collection<UIRiskCommonIssue>> getRiskCommonIssueList(Long riskSubCategoryId){
//		callWithResult[
//			return riskService.getRiskCommonIssueList(riskSubCategoryId)
//		]
//	}
//	
//	// 创建隐患大类
//	@RequestMapping(value="/windbell/createRiskCategory", method=RequestMethod.POST)
//	def RestResult createRiskCategory(@RequestBody UIRiskCategory riskCategory){
//		callWithResult[
//			return riskService.createRiskCategory(riskCategory)
//		]
//	}
//	// 创建隐患小类
//	@RequestMapping(value="/windbell/createRiskSubCategory", method=RequestMethod.POST)
//	def RestResult createRiskSubCategory(Long riskCategoryId, @RequestBody UIRiskSubCategory riskSubCategory){
//		callWithResult[
//			return riskService.createRiskSubCategory(riskCategoryId, riskSubCategory)
//		]
//	}
//	// 创建隐患不合格项
//	@RequestMapping(value="/windbell/createRiskCommonIssue", method=RequestMethod.POST)
//	def RestResult createRiskCommonIssue(Long riskSubCategoryId, @RequestBody UIRiskCommonIssue riskCommonIssue){
//		callWithResult[
//			return riskService.createRiskCommonIssue(riskSubCategoryId, riskCommonIssue)
//		]
//	}
//
//	
//	// 更新隐患大类
//	@RequestMapping(value="/windbell/updateRiskCategory", method=RequestMethod.POST)
//	def RestResult updateRiskCategory(@RequestBody UIRiskCategory riskCategory){
//		callWithResult[
//			return riskService.updateRiskCategory(riskCategory)
//		]
//	}
//	// 更新隐患小类
//	@RequestMapping(value="/windbell/updateRiskSubCategory", method=RequestMethod.POST)
//	def RestResult updateRiskSubCategory(@RequestBody UIRiskSubCategory riskSubCategory){
//		callWithResult[
//			return riskService.updateRiskSubCategory(riskSubCategory)
//		]
//	}
//	// 更新隐患不合格项
//	@RequestMapping(value="/windbell/updateCommonIssue", method=RequestMethod.POST)
//	def RestResult updateCommonIssue(@RequestBody UIRiskCommonIssue riskCommonIssue){
//		callWithResult[
//			return riskService.updateCommonIssue(riskCommonIssue)
//		]
//	}
//	
//	// 删除隐患大类
//	@RequestMapping(value="/windbell/deleteRiskCategory")
//	def RestResult deleteRiskCategory(Long riskCategoryId){
//		call[
//			riskService.deleteRiskCategory(riskCategoryId)
//		]
//	}
//	// 删除隐患小类
//	@RequestMapping(value="/windbell/deleteRiskSubCategory")
//	def RestResult deleteRiskSubCategory(Long riskSubCategoryId){
//		call[
//			riskService.deleteRiskSubCategory(riskSubCategoryId)
//		]
//	}
//	// 删除隐患不合格项
//	@RequestMapping(value="/windbell/deleteRiskCommonIssue")
//	def RestResult deleteRiskCommonIssue(Long riskCommonIssueId){
//		call[
//			riskService.deleteRiskCommonIssue(riskCommonIssueId)
//		]
//	}
//	
//	@RestRequestInfo(name="查询隐患大类")
//	@RequestMapping(value="/windbell/query/riskCategories", method=RequestMethod.POST)
//	def RestResult getRiskCategoryList( @RequestBody  UIRiskCategoryCriteria criteria){
//		callWithResult[
//			riskService.getRiskCategoryList(criteria)
//		]
//	}
	
	/**
	 * 隐患排查任务相关
	 */
//	@RestRequestInfo(name="获取隐患排查任务列表|管理员")
//	@GetMapping("/windbell/riskCheck/list")
//	def RestResult<Collection<UIRiskCheck>> riskCheckList() {
//		callWithResult[
//			return riskService.riskCheckList
//		]
//	}
	
	@RestRequestInfo(name="获取隐患排查任务列表|管理员")
	@PostMapping("/windbell/riskCheck/list")
	def RestResult riskCheckList(@RequestBody UIRiskCheckCriteria uiCriteria) {
		callWithResult[
			return riskService.getRiskCheckList(uiCriteria)
		]
	}
	
	@RestRequestInfo(name="获取隐患排查任务详情|管理员")
	@GetMapping("/windbell/riskCheck/{id}")
    def RestResult<UIRiskCheck> getRiskCheckDetail(@PathVariable Long id){
    	callWithResult[
			return riskService.riskCheckDetail(id)
		]
    }

    @RestRequestInfo(name="获取隐患排查检查条目列表|专家")
	@PostMapping("/windbell/riskCheckItem/list")
	def RestResult riskCheckItemList(@RequestBody UIRiskCheckItemCriteria uiCriteria) {
		callWithResult[
			return riskService.getRiskCheckItemList(uiCriteria)
		]
	}
	
	@RestRequestInfo(name="获取隐患排查检查条目详情|专家")
	@GetMapping("/windbell/riskCheckItem/{id}")
    def RestResult<UIRiskCheckItem> getRiskCheckItemDetail(@PathVariable Long id){
    	callWithResult[
			return riskService.riskCheckItemDetail(id)
		]
    }
    
    @RestRequestInfo(name="为检查条目添加隐患报告")
	@PostMapping("/windbell/riskCheckItem/{id}/report")
	def RestResult createRiskReport(@PathVariable Long id, @RequestBody UIRiskReport report) {
		callWithResult[
			return riskService.createRiskReport(id, report)
		]
	}
	
	@RestRequestInfo(name="隐患报告列表")
	@GetMapping("/windbell/riskReport/list")
	def RestResult riskReportList() {
		callWithResult[
			return riskService.riskReportList()
		]
	}
	
	@RestRequestInfo(name="隐患报告详情")
	@GetMapping("/windbell/riskCheckItem/{id}/report")
	def RestResult riskReportDetail(@PathVariable Long id) {
		callWithResult[
			return riskService.riskReportDetail(id)
		]
	}
	
	
	@RestRequestInfo(name="获取隐患类型列表")
	@GetMapping("/windbell/riskType")
    def RestResult<Collection<UIRiskType>> getRiskType(){
    	callWithResult[
			return riskService.getRiskType()
		]
    }
    
    @RestRequestInfo(name="获取隐患级别列表")
	@GetMapping("/windbell/riskLevel")
    def RestResult<Collection<UIRiskLevel>> getRiskLevel(){
    	callWithResult[
			return riskService.getRiskLevel()
		]
    }
    
    @RestRequestInfo(name="获取隐患来源列表")
	@GetMapping("/windbell/riskCause")
    def RestResult<Collection<UIRiskCause>> getRiskCause(){
    	callWithResult[
			return riskService.getRiskCause()
		]
    }
    
    @RestRequestInfo(name="获取整改类型列表")
	@GetMapping("/windbell/riskFixType")
    def RestResult<Collection<UIRiskFixType>> getRiskFixType(){
    	callWithResult[
			return riskService.getRiskFixType()
		]
    }
    
    @RestRequestInfo(name="获取隐患排查单位列表")
	@GetMapping("/windbell/checkTarget")
    def RestResult<Collection<UIRiskCheckTarget>> checkTargetList(){
    	callWithResult[
			return riskService.getCheckTarget()
		]
    }
    
    @RestRequestInfo(name="获取隐患排查状态列表")
	@GetMapping("/windbell/riskCheckStatus")
    def RestResult<Collection<RestRiskCheckStatus>> riskCheckStatusList(){
    	callWithResult[
			return riskService.riskCheckStatusList()
		]
    }
    
    @RestRequestInfo(name="获取检查项目状态列表")
	@GetMapping("/windbell/riskCheckItemStatus")
    def RestResult<Collection<RestRiskCheckItemStatus>> riskCheckItemStatusList(){
    	callWithResult[
			return riskService.riskCheckItemStatusList()
		]
    }
	

}